//
//  XRNoteBook.m
//  XRNoteBook
//
//  Created by 王晓冉 on 2018/6/29.
//  Copyright © 2018年 王晓冉. All rights reserved.
//

#import "XRNoteBook.h"

@implementation XRNoteBook
#pragma mark - 判断
+(BOOL)isDictionary:(id)dic{
    if (!dic) {
        return NO;
    }
    if ((NSNull *)dic == [NSNull null]) {
        return NO;
    }
    if (![dic isKindOfClass:[NSDictionary class]]) {
        return NO;
    }
    if ([dic count] <= 0) {
        return NO;
    }
    return YES;
}
+ (BOOL)isArray:(id)array{
    if (!array) {
        return NO;
    }
    if ((NSNull *)array == [NSNull null]) {
        return NO;
    }
    if (![array isKindOfClass:[NSArray class]]) {
        return NO;
    }
    if ([array count] <= 0) {
        return NO;
    }
    if (array == nil) {
        NO;
    }
    return YES;
}
+(BOOL)isArrayEmpty:(NSArray *)array
{
    return (array == nil || [array count] == 0);
}
+(BOOL)isString:(id)str{
    if (!str) {
        return NO;
    }
    if ((NSNull *)str == [NSNull null]) {
        return NO;
    }
    if (![str isKindOfClass:[NSString class]]) {
        return NO;
    }
    if ([str isEqualToString:@""]) {
        return NO;
    }
    if (((NSString *)str).length == 0) {
        return NO;
    }
    if ([str isEqualToString:@"(null)"]) {
        return NO;
    }
    if ([str isEqualToString:@"<null>"]) {
        return NO;
    }
    if ([str isKindOfClass:[NSNull class]]) {
        return NO;
    }
    return YES;
}
#pragma 手机号判断
+(BOOL)isMobileNum:(NSString *)mobNum{
    //    电信号段:133/149/153/173/177/180/181/189
    //    联通号段:130/131/132/145/155/156/171/175/176/185/186
    //    移动号段:134/135/136/137/138/139/147/150/151/152/157/158/159/178/182/183/184/187/188
    //    虚拟运营商:170
    
    NSString *MOBILE = @"^1(3[0-9]|4[579]|5[0-35-9]|7[0135-8]|8[0-9])\\d{8}$";
    
    NSPredicate *regextestmobile = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", MOBILE];
    
    return [regextestmobile evaluateWithObject:mobNum];
}
@end
